package com.shenzhen.horselive.common;


/**
 * Created by ymh on 2016/7/1 0001.
 */
public class Events {


    /**
     * 关闭
     */
    public static class CloseEvent {
        public static final String FINISH_ALL = "finishAll";
        public static final String FINISH_POST_AD = "finishPostAd";
        public String eventType;
        public final String[] ignoreClass;

        public CloseEvent(String eventType, String... ignoreClass) {
            this.eventType = eventType;
            this.ignoreClass = ignoreClass;
        }
    }

    public static class UserDataEvent {
        public final String[] keys;
        public String data;

        public UserDataEvent(String... keys) {
            this.keys = keys;
        }

        public String getData() {
            return data;
        }

        public UserDataEvent setData(String data) {
            this.data = data;
            return this;
        }

        public String keyAt(int index) {
            return keys[index];
        }

        public boolean isUpdateAll() {
            return keys == null || keys.length == 0;
        }

        public boolean contain(String key) {
            if (keys == null || keys.length == 0) {
                return true;
            } else {
                for (int i = 0; i < keys.length; i++) {
                    if (key.equals(keys[i])) {
                        return true;
                    }
                }
                return false;
            }
        }

        public boolean containOnly(String key) {
            if (keys.length == 1 && key.equals(keys[0])) {
                return true;
            }
            return false;
        }

    }


    public static class UserChangedEvent {
        public static final int SIGN_IN = 0;
        public static final int SIGN_OUT = 1;
        public final int eventType;

        public UserChangedEvent(int eventType) {
            this.eventType = eventType;
        }
    }

    public static class PushEvent {
        public static final String MSG_CENTER = "push_msg_center";
        public final String eventType;

        public PushEvent(String eventType) {
            this.eventType = eventType;
        }
    }


    /**
     * 配置更改
     */
    public static class ConfigChangeEvent {
        public ConfigChangeEvent(String[] changedKeys) {
            this.changedKeys = changedKeys;
        }

        public final String[] changedKeys;

        public String keyAt(int index) {
            return changedKeys[index];
        }

        public boolean contain(String key) {
            if (changedKeys == null || changedKeys.length == 0) {
                return true;
            } else {
                for (int i = 0; i < changedKeys.length; i++) {
                    if (key.equals(changedKeys[i])) {
                        return true;
                    }
                }
                return false;
            }
        }
    }

    public static class PermissionGrantedEvent {
        public final String[] permission;

        public PermissionGrantedEvent(String... permission) {
            this.permission = permission;
        }

        public boolean contain(String permission) {
            return permission != null && permission.contains(permission);
        }
    }

    public static class BeginnerTaskEvent {
        public static final int OVER = 0;

        public int amount;
        public final int eventType;

        public BeginnerTaskEvent(int eventType, int amount) {
            this.eventType = eventType;
            this.amount = amount;
        }
    }

    public static class EnergyEvent {
        public static final int ENERGY_NOT_ENOUGH = 0;
        public final int eventType;

        public EnergyEvent(int eventType) {
            this.eventType = eventType;
        }
    }

    public static class SharePyqEvent {

        public SharePyqEvent() {

        }
    }

    public static class WxLoginEventCode {
        public String wxLoginCode;

        public WxLoginEventCode(String wxLoginCode) {
            this.wxLoginCode = wxLoginCode;
        }
    }
}
